package com.mc.lp.database.entity.helper;

import com.mc.lp.database.entity.GradeYearMapperEntity;
import com.mc.lp.database.entity.type.SchoolGrade;
import com.mc.lp.shared.vo.GradeMappingVo;
/*
 * @author aphanda
 * @date Mar 23, 2015
 * @time 9:29:58 PM
 */

public class GradeYearMapperHelper implements IEntityHelper<GradeYearMapperEntity, GradeMappingVo>{

	@Override
	public GradeMappingVo getVO(GradeYearMapperEntity en) {
		GradeMappingVo vo = new GradeMappingVo();
		vo.setGradeId(Long.valueOf(en.getSchoolGrade()));
		vo.setEndYear(Integer.toString(en.getEndYear()));
		vo.setStartYear(Integer.toString(en.getStartYear()));
		vo.setStudentId(en.getEntity().getId());
		vo.setId(en.getId());
		vo.setGradeName(SchoolGrade.getSchoolGradeName(en.getSchoolGrade()));
		
		return vo;
	}

	@Override
	public GradeYearMapperEntity getEntity(GradeMappingVo vo) {
		GradeYearMapperEntity en = new GradeYearMapperEntity();
		en.setEndYear(Integer.parseInt(vo.getEndYear()));
		en.setSchoolGrade(vo.getGradeId().intValue());
		en.setStartYear(Integer.parseInt(vo.getStartYear()));
		
		return en;
	}

	@Override
	public void setEntity(GradeMappingVo vo, GradeYearMapperEntity entity) {
		entity.setEndYear(Integer.parseInt(vo.getEndYear()));
		entity.setSchoolGrade(vo.getGradeId().intValue());
		entity.setStartYear(Integer.parseInt(vo.getStartYear()));	
	}

}
